const TransformPages = require('uni-read-pages')
const {
  webpack
} = new TransformPages()

let configEnv = {}
if (process.env.NODE_ENV == 'development') configEnv = require('./src/static/js/env/libs/env.dev')
if (process.env.NODE_ENV == 'production') configEnv = require('./src/static/js/env/libs/env.prod')

module.exports = {
  transpileDependencies: ['uview-ui'],
  configureWebpack: {
    plugins: [
      new webpack.DefinePlugin({

        ROUTES: webpack.DefinePlugin.runtimeValue(() => {
          const tfPages = new TransformPages({
            includes: ['path', 'name', 'aliasPath']
          });
          return JSON.stringify(tfPages.routes)
        }, true)
      })
    ]
  },
  devServer: {
    proxy: {
      '/dpc': {
        target: configEnv.baseUrl,
        pathRewrite: {
          '^/dpc': ''
        }
      }
    },
    client: {
      overlay: false
    }
  }
};